import java.io.*;

class CompilerDriver
{
    public static void main(String argv[]) throws Exception 
    {
    	FileInputStream is = new FileInputStream(argv[0]);
	try 
        {
	    Parser parser_obj = new Parser(new Yylex(is));
	    Ast.Program prog = (Ast.Program) parser_obj.parse().value;
	    Check.check(prog);
	    Compiler.compile(prog);
	} catch (ParseError exn) {
	    System.err.println(exn.getMessage());
	} catch (Check.CheckError exn) {
	    System.err.println(exn.getMessage());
	} catch (Compiler.CompilerError exn) {
	    System.err.println(exn.getMessage());
	}
    }
}
